home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kio / previewjob.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-01-19  |  7.0 KB  |  183 lines

  1. // -*- c++ -*-
  2. // vim: ts=4 sw=4 et
  3. /*  This file is part of the KDE libraries
  4.     Copyright (C) 2000 David Faure <faure@kde.org>
  5.                   2000 Carsten Pfeiffer <pfeiffer@kde.org>
  6.                   2001 Malte Starostik <malte.starostik@t-online.de>
  7.  
  8.     This library is free software; you can redistribute it and/or
  9.     modify it under the terms of the GNU Library General Public
  10.     License as published by the Free Software Foundation; either
  11.     version 2 of the License, or (at your option) any later version.
  12.  
  13.     This library is distributed in the hope that it will be useful,
  14.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.     Library General Public License for more details.
  17.  
  18.     You should have received a copy of the GNU Library General Public License
  19.     along with this library; see the file COPYING.LIB.  If not, write to
  20.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21.     Boston, MA 02110-1301, USA.
  22. */
  23.  
  24. #ifndef __kio_previewjob_h__
  25. #define __kio_previewjob_h__
  26.  
  27. #include <kfileitem.h>
  28. #include <kio/job.h>
  29.  
  30. class QPixmap;
  31.  
  32. namespace KIO {
  33.     /*!
  34.      * This class catches a preview (thumbnail) for files.
  35.      * @short KIO Job to get a thumbnail picture
  36.      */
  37.     class KIO_EXPORT PreviewJob : public KIO::Job
  38.     {
  39.         Q_OBJECT
  40.     public:
  41.     /**
  42.      * Creates a new PreviewJob.
  43.      * @param items a list of files to create previews for
  44.      * @param width the desired width
  45.      * @param height the desired height, 0 to use the @p width
  46.      * @param iconSize the size of the mimetype icon to overlay over the
  47.      * preview or zero to not overlay an icon. This has no effect if the
  48.      * preview plugin that will be used doesn't use icon overlays.
  49.      * @param iconAlpha transparency to use for the icon overlay
  50.      * @param scale if the image is to be scaled to the requested size or
  51.      * returned in its original size
  52.      * @param save if the image should be cached for later use
  53.      * @param enabledPlugins if non-zero, this points to a list containing
  54.      * the names of the plugins that may be used.
  55.      * @param deleteItems true to delete the items when done
  56.      */
  57.         PreviewJob( const KFileItemList &items, int width, int height,
  58.             int iconSize, int iconAlpha, bool scale, bool save,
  59.             const QStringList *enabledPlugins, bool deleteItems = false );
  60.         virtual ~PreviewJob();
  61.  
  62.         /**
  63.          * Removes an item from preview processing. Use this if you passed
  64.          * an item to filePreview and want to delete it now.
  65.          *
  66.          * @param item the item that should be removed from the preview queue
  67.          */
  68.         void removeItem( const KFileItem *item );
  69.  
  70.         /**
  71.          * If @p ignoreSize is true, then the preview is always 
  72.          * generated regardless of the settings
  73.          *
  74.          * @since KDE 3.4
  75.          **/
  76.         void setIgnoreMaximumSize(bool ignoreSize = true);
  77.  
  78.         /**
  79.          * Returns a list of all available preview plugins. The list
  80.          * contains the basenames of the plugins' .desktop files (no path,
  81.          * no .desktop).
  82.      * @return the list of plugins
  83.          */
  84.         static QStringList availablePlugins();
  85.  
  86.         /**
  87.          * Returns a list of all supported MIME types. The list can
  88.          * contain entries like text/ * (without the space).
  89.      * @return the list of mime types
  90.          */
  91.         static QStringList supportedMimeTypes();
  92.  
  93.         /**
  94.          * Reimplemented for internal reasons
  95.          */
  96.         virtual void kill( bool quietly = true );
  97.  
  98.     signals:
  99.         /**
  100.          * Emitted when a thumbnail picture for @p item has been successfully
  101.          * retrieved.
  102.      * @param item the file of the preview
  103.      * @param preview the preview image
  104.          */
  105.         void gotPreview( const KFileItem *item, const QPixmap &preview );
  106.         /**
  107.          * Emitted when a thumbnail for @p item could not be created,
  108.          * either because a ThumbCreator for its MIME type does not
  109.          * exist, or because something went wrong.
  110.      * @param item the file that failed
  111.          */
  112.         void failed( const KFileItem *item );
  113.  
  114.     protected:
  115.         void getOrCreateThumbnail();
  116.         bool statResultThumbnail();
  117.         void createThumbnail( QString );
  118.  
  119.     protected slots:
  120.         virtual void slotResult( KIO::Job *job );
  121.  
  122.     private slots:
  123.         void startPreview();
  124.         void slotThumbData(KIO::Job *, const QByteArray &);
  125.  
  126.     private:
  127.         void determineNextFile();
  128.         void emitPreview(const QImage &thumb);
  129.         void emitFailed(const KFileItem *item = 0);
  130.  
  131.     protected:
  132.     virtual void virtual_hook( int id, void* data );
  133.     private:
  134.         struct PreviewJobPrivate *d;
  135.     };
  136.  
  137.     /**
  138.      * Creates a PreviewJob to generate or retrieve a preview image 
  139.      * for the given URL.
  140.      *
  141.      * @param items files to get previews for
  142.      * @param width the maximum width to use
  143.      * @param height the maximum height to use, if this is 0, the same
  144.      * value as width is used.
  145.      * @param iconSize the size of the mimetype icon to overlay over the
  146.      * preview or zero to not overlay an icon. This has no effect if the
  147.      * preview plugin that will be used doesn't use icon overlays.
  148.      * @param iconAlpha transparency to use for the icon overlay
  149.      * @param scale if the image is to be scaled to the requested size or
  150.      * returned in its original size
  151.      * @param save if the image should be cached for later use
  152.      * @param enabledPlugins if non-zero, this points to a list containing
  153.      * the names of the plugins that may be used.
  154.      * @return the new PreviewJob
  155.      * @see PreviewJob::availablePlugins()
  156.      */
  157.     KIO_EXPORT PreviewJob *filePreview( const KFileItemList &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 );
  158.  
  159.     /**
  160.      * Creates a PreviewJob to generate or retrieve a preview image 
  161.      * for the given URL.
  162.      *
  163.      * @param items files to get previews for
  164.      * @param width the maximum width to use
  165.      * @param height the maximum height to use, if this is 0, the same
  166.      * value as width is used.
  167.      * @param iconSize the size of the mimetype icon to overlay over the
  168.      * preview or zero to not overlay an icon. This has no effect if the
  169.      * preview plugin that will be used doesn't use icon overlays.
  170.      * @param iconAlpha transparency to use for the icon overlay
  171.      * @param scale if the image is to be scaled to the requested size or
  172.      * returned in its original size
  173.      * @param save if the image should be cached for later use
  174.      * @param enabledPlugins if non-zero, this points to a list containing
  175.      * the names of the plugins that may be used.
  176.      * @return the new PreviewJob
  177.      * @see PreviewJob::availablePlugins()
  178.      */
  179.     KIO_EXPORT PreviewJob *filePreview( const KURL::List &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 );
  180. }
  181.  
  182. #endif
  183.